/**
 * 
 */
package com.module.bp.player;

import com.module.bp.script.BPScriptable;
import com.rpg.base.flyweight.IOPCData;

/**
 * @author Donald
 *
 */
public abstract class BPCharacter extends IOPCData implements BPScriptable {
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void init() {
		super.initAbilityScores(BPConsts.ABILITY_TOTAL);
		onInit();
	}
	/** the character's salary, if a hireling. */
	private int salary;
	/**
	 * Gets the character's salary.
	 * @return <code>int</code>
	 */
	public final int getSalary() {
		return salary;
	}
	/** 
	 * the list of areas where the {@link BPCharacter}
	 * can function as a local guide.
	 */
	private int[] guideLocations = new int[0];
	/**
	 * Determines if the {@link BPCharacter} can function as a local guide for a
	 * specific location.
	 * @param locationIndex the location
	 * @return true if the {@link BPCharacter} can act as a guide for that area;
	 * false otherwise
	 */
	public final boolean isGuideForLocation(final int locationIndex) {
		boolean has = false;
		for (int i = 0; i < guideLocations.length; i++) {
			if (guideLocations[i] == locationIndex) {
				has = true;
				break;
			}
		}
		return has;
	}
	/**
	 * Adds areas where the {@link BPCharacter} can function as a local guide.
	 * @param locations the list of locations being added
	 */
	public final void addGuideLocations(final int... locations) {
		int offset = guideLocations.length;
		int[] dest = new int[offset + locations.length];
		System.arraycopy(guideLocations, 0, dest, 0, guideLocations.length);
		guideLocations = dest;
		dest = null;
		for (int i = 0; i < locations.length; i++) {
			guideLocations[offset + i] = locations[i];
		}
	}
}
